<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="./lib/jquery.js"></script>
  <script src="./lib/x2js.js"></script>
</head>
<body>
  <script>
    var x2js = new X2JS()
    console.log(x2js)
    $.ajax('./data/9223370416979999536.gpx').done(function (data) {
      // console.log(x2js.xml2dom(data)) // null
      console.log(x2js.dom2js(data)) // 数据
    })
    $.ajax({
      url: './data/e.xml',
      method: 'get',
      dataType: 'xml',
      success: function (data) {
        // console.log(data) // 返回的是dom节点
        // console.log('xml2dom:', x2js.xml2dom(data)) // null
        // console.log('xml2js:', x2js.xml2js(data)) // null
        // console.log('xml2dom:', x2js.xml2dom(data)) // null
      }
    })
    var obj = {
      node: {
        name: '张三',
        age: 24
      }
    }
    console.log(x2js.js2xml(obj))
    /**
     * <node>
     *   <name>张三</name>
     *   <age>24</age>
     * </node>
     */
    console.log(x2js.js2dom(obj))
    /**
     * #document
     *  <node>
     *    <name>张三</name>
     *    <age>24</age>
     *  </node>
     */
  </script>
</body>
</html>